# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=td-agent-bit
_pkgname=fluent-bit
pkgver=0.10.1
pkgrel=3
pkgdesc="Fast and Lightweight Log/Data Forwarder [fluent-bit]"
url="http://fluentbit.io"
arch="all !aarch64 !s390x !mips !mips64"
license="Apache-2.0"
makedepends="cmake linux-headers zlib-dev mbedtls-dev"
subpackages="$pkgname-dev $pkgname-doc"
source="http://fluentbit.io/releases/0.10/$_pkgname-$pkgver.tar.gz
	$pkgname.confd
	$pkgname.initd
	disable-jemalloc.patch
	0001-lib-flb_libco-Fix-ppc64-function-arguments.patch
	"
builddir="$srcdir/"$_pkgname-$pkgver

build() {
	cd "$builddir"/build
	cmake \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_SYSCONFDIR=/etc \
		-DCMAKE_INSTALL_LIBDIR:PATH=lib \
		-DCMAKE_C_FLAGS="$CFLAGS -Wno-implicit-fallthrough" \
		-DFLB_ALL=ON \
		-DFLB_TD=ON ..
	make || return 1
}

package() {
	cd "$builddir"/build

	make DESTDIR="$pkgdir" install || return 1

	install -m644 -D ../README.md \
		"$pkgdir"/usr/share/doc/$pkgname/README.md || return 1
	install -m644 -D ../LICENSE \
		"$pkgdir"/usr/share/licenses/$pkgname/LICENSE || return 1

	install -m644 -D "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname || return 1
	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname || return 1
}

sha512sums="93b1e6c277ebecb65e40d078d98f1942dcda7fa02abd1f8c2d95e4c73d20ec36bee0d0d072b7624894a5b75a455d5c25b91a08c6a05e391b40a03a63a15e3096  fluent-bit-0.10.1.tar.gz
6c1c67ac965fb9f54e362a7de8864afbffb9a22bffb5b5ca3a68f3950b9a27ccaee29d4bfb223035ccf5276e3fe09d0873685c58c47e055ad4bea57ccf80d90e  td-agent-bit.confd
5103ab108bf0bafec2ca34db6e3a629977cd0a6ffb3f213b3885af5e2c08218ede4784d64310d6acdc7a09a9bc1e29330eaf692dbebdc6619de5a69cb1f80948  td-agent-bit.initd
bf41aa1eef5ae0239acb2f54356d090d71611eb021de5b0d92be10079ef3bc5c7cc1dade1de98fd60354b883e53652a6f3f54a7a03acd00471e1f65d654aac32  disable-jemalloc.patch
cf78d431e23c9c14d1564b6c4f6bc6d1645a2d3a74a276eb1a0a50f9d1725b04cb83f368337293f2493b9940459fa3ee7c59bbd2b2f3f67faeb4c5ac20787ddb  0001-lib-flb_libco-Fix-ppc64-function-arguments.patch"
